package com.augurit.wf.bi.convert;

import java.util.ArrayList;
import java.util.List;

import com.augurit.common.base.extmodel.inner.AppTreeNode;
import com.augurit.common.base.extmodel.inner.MultiEntityTreeNode;
import com.augurit.wf.bi.web.form.WfBusTemplateForm;
import com.augurit.wf.bi.web.form.WfBusTemplateTypeForm;
import com.augurit.wf.common.extmodel.BusTemplateNode;

public class BusTemplateNodeConvertor {
	
	
	/**
	 * 构造业务流程模板树上的模板类型结点
	 * @param form
	 * @return
	 */
	public static BusTemplateNode convertToTypeNode(WfBusTemplateTypeForm form){
		BusTemplateNode node = null;
		if(form != null){
			node = new BusTemplateNode();
//			node.setId(form.getId().toString());
			node.setText(form.getTemplateTypeName());
			node.setEntityId(form.getId());
			node.setIconCls(MultiEntityTreeNode.DEFAULT_NOT_LEAF_TREE_NODE_CLS);
			node.setLeaf(false);
		}
	
		return node;
	}
	
	/**
	 * 构造业务流程模板树上的模板结点
	 * @param form
	 * @return
	 */
	public static BusTemplateNode convertToTemplateNode(WfBusTemplateForm form){
		BusTemplateNode node = null;
		if(form != null){
			node = new BusTemplateNode();
//			node.setId(form.getId().toString());
			node.setText(form.getTemplateName());
			node.setEntityId(form.getId());
			node.setIconCls(AppTreeNode.DEFAULT_LEAF_TREE_NODE_CLS);
			node.setLeaf(true);
		}
		return node;
	}
	
	public static List<BusTemplateNode> convertCodesToList(List<WfBusTemplateTypeForm> forms){
		List<BusTemplateNode> nodes = null;
		if(forms != null && forms.size() > 0){
			nodes = new ArrayList<BusTemplateNode>();
			for(WfBusTemplateTypeForm form : forms){
				BusTemplateNode node = convertToTypeNode(form);
				nodes.add(node);
			}
		}
		return nodes;
	}
	
	public static List<BusTemplateNode> convertTemplatesToList(List<WfBusTemplateForm> forms){
		List<BusTemplateNode> nodes = null;
		if(forms != null && forms.size() > 0){
			nodes = new ArrayList<BusTemplateNode>();
			for(WfBusTemplateForm form:forms){
				BusTemplateNode node = convertToTemplateNode(form);
				nodes.add(node);
			}
		}
		return nodes;
	}
	
	
}
